/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";

var $protobuf = require("./protobuf");

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.Msg = (function() {

    /**
     * Namespace Msg.
     * @exports Msg
     * @namespace
     */
    var Msg = {};

    Msg.RegR = (function() {

        /**
         * Properties of a RegR.
         * @memberof Msg
         * @interface IRegR
         * @property {string} username RegR username
         * @property {string} password RegR password
         */

        /**
         * Constructs a new RegR.
         * @memberof Msg
         * @classdesc Represents a RegR.
         * @implements IRegR
         * @constructor
         * @param {Msg.IRegR=} [properties] Properties to set
         */
        function RegR(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * RegR username.
         * @member {string} username
         * @memberof Msg.RegR
         * @instance
         */
        RegR.prototype.username = "";

        /**
         * RegR password.
         * @member {string} password
         * @memberof Msg.RegR
         * @instance
         */
        RegR.prototype.password = "";

        /**
         * Creates a new RegR instance using the specified properties.
         * @function create
         * @memberof Msg.RegR
         * @static
         * @param {Msg.IRegR=} [properties] Properties to set
         * @returns {Msg.RegR} RegR instance
         */
        RegR.create = function create(properties) {
            return new RegR(properties);
        };

        /**
         * Encodes the specified RegR message. Does not implicitly {@link Msg.RegR.verify|verify} messages.
         * @function encode
         * @memberof Msg.RegR
         * @static
         * @param {Msg.IRegR} message RegR message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        RegR.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.username);
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.password);
            return writer;
        };

        /**
         * Encodes the specified RegR message, length delimited. Does not implicitly {@link Msg.RegR.verify|verify} messages.
         * @function encodeDelimited
         * @memberof Msg.RegR
         * @static
         * @param {Msg.IRegR} message RegR message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        RegR.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a RegR message from the specified reader or buffer.
         * @function decode
         * @memberof Msg.RegR
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {Msg.RegR} RegR
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        RegR.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Msg.RegR();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.username = reader.string();
                    break;
                case 2:
                    message.password = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("username"))
                throw $util.ProtocolError("missing required 'username'", { instance: message });
            if (!message.hasOwnProperty("password"))
                throw $util.ProtocolError("missing required 'password'", { instance: message });
            return message;
        };

        /**
         * Decodes a RegR message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof Msg.RegR
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {Msg.RegR} RegR
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        RegR.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a RegR message.
         * @function verify
         * @memberof Msg.RegR
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        RegR.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isString(message.username))
                return "username: string expected";
            if (!$util.isString(message.password))
                return "password: string expected";
            return null;
        };

        /**
         * Creates a RegR message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof Msg.RegR
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {Msg.RegR} RegR
         */
        RegR.fromObject = function fromObject(object) {
            if (object instanceof $root.Msg.RegR)
                return object;
            var message = new $root.Msg.RegR();
            if (object.username != null)
                message.username = String(object.username);
            if (object.password != null)
                message.password = String(object.password);
            return message;
        };

        /**
         * Creates a plain object from a RegR message. Also converts values to other types if specified.
         * @function toObject
         * @memberof Msg.RegR
         * @static
         * @param {Msg.RegR} message RegR
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        RegR.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.username = "";
                object.password = "";
            }
            if (message.username != null && message.hasOwnProperty("username"))
                object.username = message.username;
            if (message.password != null && message.hasOwnProperty("password"))
                object.password = message.password;
            return object;
        };

        /**
         * Converts this RegR to JSON.
         * @function toJSON
         * @memberof Msg.RegR
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        RegR.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return RegR;
    })();

    Msg.RegA = (function() {

        /**
         * Properties of a RegA.
         * @memberof Msg
         * @interface IRegA
         * @property {number} code RegA code
         * @property {string} msg RegA msg
         */

        /**
         * Constructs a new RegA.
         * @memberof Msg
         * @classdesc Represents a RegA.
         * @implements IRegA
         * @constructor
         * @param {Msg.IRegA=} [properties] Properties to set
         */
        function RegA(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * RegA code.
         * @member {number} code
         * @memberof Msg.RegA
         * @instance
         */
        RegA.prototype.code = 0;

        /**
         * RegA msg.
         * @member {string} msg
         * @memberof Msg.RegA
         * @instance
         */
        RegA.prototype.msg = "";

        /**
         * Creates a new RegA instance using the specified properties.
         * @function create
         * @memberof Msg.RegA
         * @static
         * @param {Msg.IRegA=} [properties] Properties to set
         * @returns {Msg.RegA} RegA instance
         */
        RegA.create = function create(properties) {
            return new RegA(properties);
        };

        /**
         * Encodes the specified RegA message. Does not implicitly {@link Msg.RegA.verify|verify} messages.
         * @function encode
         * @memberof Msg.RegA
         * @static
         * @param {Msg.IRegA} message RegA message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        RegA.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code);
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.msg);
            return writer;
        };

        /**
         * Encodes the specified RegA message, length delimited. Does not implicitly {@link Msg.RegA.verify|verify} messages.
         * @function encodeDelimited
         * @memberof Msg.RegA
         * @static
         * @param {Msg.IRegA} message RegA message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        RegA.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a RegA message from the specified reader or buffer.
         * @function decode
         * @memberof Msg.RegA
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {Msg.RegA} RegA
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        RegA.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Msg.RegA();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.code = reader.int32();
                    break;
                case 2:
                    message.msg = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("code"))
                throw $util.ProtocolError("missing required 'code'", { instance: message });
            if (!message.hasOwnProperty("msg"))
                throw $util.ProtocolError("missing required 'msg'", { instance: message });
            return message;
        };

        /**
         * Decodes a RegA message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof Msg.RegA
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {Msg.RegA} RegA
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        RegA.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a RegA message.
         * @function verify
         * @memberof Msg.RegA
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        RegA.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isInteger(message.code))
                return "code: integer expected";
            if (!$util.isString(message.msg))
                return "msg: string expected";
            return null;
        };

        /**
         * Creates a RegA message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof Msg.RegA
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {Msg.RegA} RegA
         */
        RegA.fromObject = function fromObject(object) {
            if (object instanceof $root.Msg.RegA)
                return object;
            var message = new $root.Msg.RegA();
            if (object.code != null)
                message.code = object.code | 0;
            if (object.msg != null)
                message.msg = String(object.msg);
            return message;
        };

        /**
         * Creates a plain object from a RegA message. Also converts values to other types if specified.
         * @function toObject
         * @memberof Msg.RegA
         * @static
         * @param {Msg.RegA} message RegA
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        RegA.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.code = 0;
                object.msg = "";
            }
            if (message.code != null && message.hasOwnProperty("code"))
                object.code = message.code;
            if (message.msg != null && message.hasOwnProperty("msg"))
                object.msg = message.msg;
            return object;
        };

        /**
         * Converts this RegA to JSON.
         * @function toJSON
         * @memberof Msg.RegA
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        RegA.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return RegA;
    })();

    Msg.UserItem = (function() {

        /**
         * Properties of a UserItem.
         * @memberof Msg
         * @interface IUserItem
         * @property {number} userid UserItem userid
         * @property {string} username UserItem username
         */

        /**
         * Constructs a new UserItem.
         * @memberof Msg
         * @classdesc Represents a UserItem.
         * @implements IUserItem
         * @constructor
         * @param {Msg.IUserItem=} [properties] Properties to set
         */
        function UserItem(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * UserItem userid.
         * @member {number} userid
         * @memberof Msg.UserItem
         * @instance
         */
        UserItem.prototype.userid = 0;

        /**
         * UserItem username.
         * @member {string} username
         * @memberof Msg.UserItem
         * @instance
         */
        UserItem.prototype.username = "";

        /**
         * Creates a new UserItem instance using the specified properties.
         * @function create
         * @memberof Msg.UserItem
         * @static
         * @param {Msg.IUserItem=} [properties] Properties to set
         * @returns {Msg.UserItem} UserItem instance
         */
        UserItem.create = function create(properties) {
            return new UserItem(properties);
        };

        /**
         * Encodes the specified UserItem message. Does not implicitly {@link Msg.UserItem.verify|verify} messages.
         * @function encode
         * @memberof Msg.UserItem
         * @static
         * @param {Msg.IUserItem} message UserItem message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        UserItem.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 0 =*/8).int32(message.userid);
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.username);
            return writer;
        };

        /**
         * Encodes the specified UserItem message, length delimited. Does not implicitly {@link Msg.UserItem.verify|verify} messages.
         * @function encodeDelimited
         * @memberof Msg.UserItem
         * @static
         * @param {Msg.IUserItem} message UserItem message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        UserItem.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a UserItem message from the specified reader or buffer.
         * @function decode
         * @memberof Msg.UserItem
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {Msg.UserItem} UserItem
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        UserItem.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Msg.UserItem();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.userid = reader.int32();
                    break;
                case 2:
                    message.username = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("userid"))
                throw $util.ProtocolError("missing required 'userid'", { instance: message });
            if (!message.hasOwnProperty("username"))
                throw $util.ProtocolError("missing required 'username'", { instance: message });
            return message;
        };

        /**
         * Decodes a UserItem message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof Msg.UserItem
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {Msg.UserItem} UserItem
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        UserItem.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a UserItem message.
         * @function verify
         * @memberof Msg.UserItem
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        UserItem.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isInteger(message.userid))
                return "userid: integer expected";
            if (!$util.isString(message.username))
                return "username: string expected";
            return null;
        };

        /**
         * Creates a UserItem message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof Msg.UserItem
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {Msg.UserItem} UserItem
         */
        UserItem.fromObject = function fromObject(object) {
            if (object instanceof $root.Msg.UserItem)
                return object;
            var message = new $root.Msg.UserItem();
            if (object.userid != null)
                message.userid = object.userid | 0;
            if (object.username != null)
                message.username = String(object.username);
            return message;
        };

        /**
         * Creates a plain object from a UserItem message. Also converts values to other types if specified.
         * @function toObject
         * @memberof Msg.UserItem
         * @static
         * @param {Msg.UserItem} message UserItem
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        UserItem.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.userid = 0;
                object.username = "";
            }
            if (message.userid != null && message.hasOwnProperty("userid"))
                object.userid = message.userid;
            if (message.username != null && message.hasOwnProperty("username"))
                object.username = message.username;
            return object;
        };

        /**
         * Converts this UserItem to JSON.
         * @function toJSON
         * @memberof Msg.UserItem
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        UserItem.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return UserItem;
    })();

    Msg.ChatMsg = (function() {

        /**
         * Properties of a ChatMsg.
         * @memberof Msg
         * @interface IChatMsg
         * @property {string} type ChatMsg type
         * @property {string} msg ChatMsg msg
         * @property {Msg.IUserItem} curuser ChatMsg curuser
         * @property {Msg.IChatUsers|null} [users] ChatMsg users
         */

        /**
         * Constructs a new ChatMsg.
         * @memberof Msg
         * @classdesc Represents a ChatMsg.
         * @implements IChatMsg
         * @constructor
         * @param {Msg.IChatMsg=} [properties] Properties to set
         */
        function ChatMsg(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * ChatMsg type.
         * @member {string} type
         * @memberof Msg.ChatMsg
         * @instance
         */
        ChatMsg.prototype.type = "";

        /**
         * ChatMsg msg.
         * @member {string} msg
         * @memberof Msg.ChatMsg
         * @instance
         */
        ChatMsg.prototype.msg = "";

        /**
         * ChatMsg curuser.
         * @member {Msg.IUserItem} curuser
         * @memberof Msg.ChatMsg
         * @instance
         */
        ChatMsg.prototype.curuser = null;

        /**
         * ChatMsg users.
         * @member {Msg.IChatUsers|null|undefined} users
         * @memberof Msg.ChatMsg
         * @instance
         */
        ChatMsg.prototype.users = null;

        /**
         * Creates a new ChatMsg instance using the specified properties.
         * @function create
         * @memberof Msg.ChatMsg
         * @static
         * @param {Msg.IChatMsg=} [properties] Properties to set
         * @returns {Msg.ChatMsg} ChatMsg instance
         */
        ChatMsg.create = function create(properties) {
            return new ChatMsg(properties);
        };

        /**
         * Encodes the specified ChatMsg message. Does not implicitly {@link Msg.ChatMsg.verify|verify} messages.
         * @function encode
         * @memberof Msg.ChatMsg
         * @static
         * @param {Msg.IChatMsg} message ChatMsg message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        ChatMsg.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.type);
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.msg);
            $root.Msg.UserItem.encode(message.curuser, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
            if (message.users != null && message.hasOwnProperty("users"))
                $root.Msg.ChatUsers.encode(message.users, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified ChatMsg message, length delimited. Does not implicitly {@link Msg.ChatMsg.verify|verify} messages.
         * @function encodeDelimited
         * @memberof Msg.ChatMsg
         * @static
         * @param {Msg.IChatMsg} message ChatMsg message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        ChatMsg.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a ChatMsg message from the specified reader or buffer.
         * @function decode
         * @memberof Msg.ChatMsg
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {Msg.ChatMsg} ChatMsg
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        ChatMsg.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Msg.ChatMsg();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.type = reader.string();
                    break;
                case 2:
                    message.msg = reader.string();
                    break;
                case 3:
                    message.curuser = $root.Msg.UserItem.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.users = $root.Msg.ChatUsers.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("type"))
                throw $util.ProtocolError("missing required 'type'", { instance: message });
            if (!message.hasOwnProperty("msg"))
                throw $util.ProtocolError("missing required 'msg'", { instance: message });
            if (!message.hasOwnProperty("curuser"))
                throw $util.ProtocolError("missing required 'curuser'", { instance: message });
            return message;
        };

        /**
         * Decodes a ChatMsg message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof Msg.ChatMsg
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {Msg.ChatMsg} ChatMsg
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        ChatMsg.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a ChatMsg message.
         * @function verify
         * @memberof Msg.ChatMsg
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        ChatMsg.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isString(message.type))
                return "type: string expected";
            if (!$util.isString(message.msg))
                return "msg: string expected";
            {
                var error = $root.Msg.UserItem.verify(message.curuser);
                if (error)
                    return "curuser." + error;
            }
            if (message.users != null && message.hasOwnProperty("users")) {
                var error = $root.Msg.ChatUsers.verify(message.users);
                if (error)
                    return "users." + error;
            }
            return null;
        };

        /**
         * Creates a ChatMsg message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof Msg.ChatMsg
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {Msg.ChatMsg} ChatMsg
         */
        ChatMsg.fromObject = function fromObject(object) {
            if (object instanceof $root.Msg.ChatMsg)
                return object;
            var message = new $root.Msg.ChatMsg();
            if (object.type != null)
                message.type = String(object.type);
            if (object.msg != null)
                message.msg = String(object.msg);
            if (object.curuser != null) {
                if (typeof object.curuser !== "object")
                    throw TypeError(".Msg.ChatMsg.curuser: object expected");
                message.curuser = $root.Msg.UserItem.fromObject(object.curuser);
            }
            if (object.users != null) {
                if (typeof object.users !== "object")
                    throw TypeError(".Msg.ChatMsg.users: object expected");
                message.users = $root.Msg.ChatUsers.fromObject(object.users);
            }
            return message;
        };

        /**
         * Creates a plain object from a ChatMsg message. Also converts values to other types if specified.
         * @function toObject
         * @memberof Msg.ChatMsg
         * @static
         * @param {Msg.ChatMsg} message ChatMsg
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        ChatMsg.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.type = "";
                object.msg = "";
                object.curuser = null;
                object.users = null;
            }
            if (message.type != null && message.hasOwnProperty("type"))
                object.type = message.type;
            if (message.msg != null && message.hasOwnProperty("msg"))
                object.msg = message.msg;
            if (message.curuser != null && message.hasOwnProperty("curuser"))
                object.curuser = $root.Msg.UserItem.toObject(message.curuser, options);
            if (message.users != null && message.hasOwnProperty("users"))
                object.users = $root.Msg.ChatUsers.toObject(message.users, options);
            return object;
        };

        /**
         * Converts this ChatMsg to JSON.
         * @function toJSON
         * @memberof Msg.ChatMsg
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        ChatMsg.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return ChatMsg;
    })();

    Msg.ChatUsers = (function() {

        /**
         * Properties of a ChatUsers.
         * @memberof Msg
         * @interface IChatUsers
         * @property {Msg.IUserItem} curuser ChatUsers curuser
         * @property {Array.<Msg.IUserItem>|null} [users] ChatUsers users
         */

        /**
         * Constructs a new ChatUsers.
         * @memberof Msg
         * @classdesc Represents a ChatUsers.
         * @implements IChatUsers
         * @constructor
         * @param {Msg.IChatUsers=} [properties] Properties to set
         */
        function ChatUsers(properties) {
            this.users = [];
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * ChatUsers curuser.
         * @member {Msg.IUserItem} curuser
         * @memberof Msg.ChatUsers
         * @instance
         */
        ChatUsers.prototype.curuser = null;

        /**
         * ChatUsers users.
         * @member {Array.<Msg.IUserItem>} users
         * @memberof Msg.ChatUsers
         * @instance
         */
        ChatUsers.prototype.users = $util.emptyArray;

        /**
         * Creates a new ChatUsers instance using the specified properties.
         * @function create
         * @memberof Msg.ChatUsers
         * @static
         * @param {Msg.IChatUsers=} [properties] Properties to set
         * @returns {Msg.ChatUsers} ChatUsers instance
         */
        ChatUsers.create = function create(properties) {
            return new ChatUsers(properties);
        };

        /**
         * Encodes the specified ChatUsers message. Does not implicitly {@link Msg.ChatUsers.verify|verify} messages.
         * @function encode
         * @memberof Msg.ChatUsers
         * @static
         * @param {Msg.IChatUsers} message ChatUsers message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        ChatUsers.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            $root.Msg.UserItem.encode(message.curuser, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
            if (message.users != null && message.users.length)
                for (var i = 0; i < message.users.length; ++i)
                    $root.Msg.UserItem.encode(message.users[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified ChatUsers message, length delimited. Does not implicitly {@link Msg.ChatUsers.verify|verify} messages.
         * @function encodeDelimited
         * @memberof Msg.ChatUsers
         * @static
         * @param {Msg.IChatUsers} message ChatUsers message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        ChatUsers.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a ChatUsers message from the specified reader or buffer.
         * @function decode
         * @memberof Msg.ChatUsers
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {Msg.ChatUsers} ChatUsers
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        ChatUsers.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Msg.ChatUsers();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.curuser = $root.Msg.UserItem.decode(reader, reader.uint32());
                    break;
                case 2:
                    if (!(message.users && message.users.length))
                        message.users = [];
                    message.users.push($root.Msg.UserItem.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("curuser"))
                throw $util.ProtocolError("missing required 'curuser'", { instance: message });
            return message;
        };

        /**
         * Decodes a ChatUsers message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof Msg.ChatUsers
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {Msg.ChatUsers} ChatUsers
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        ChatUsers.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a ChatUsers message.
         * @function verify
         * @memberof Msg.ChatUsers
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        ChatUsers.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            {
                var error = $root.Msg.UserItem.verify(message.curuser);
                if (error)
                    return "curuser." + error;
            }
            if (message.users != null && message.hasOwnProperty("users")) {
                if (!Array.isArray(message.users))
                    return "users: array expected";
                for (var i = 0; i < message.users.length; ++i) {
                    var error = $root.Msg.UserItem.verify(message.users[i]);
                    if (error)
                        return "users." + error;
                }
            }
            return null;
        };

        /**
         * Creates a ChatUsers message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof Msg.ChatUsers
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {Msg.ChatUsers} ChatUsers
         */
        ChatUsers.fromObject = function fromObject(object) {
            if (object instanceof $root.Msg.ChatUsers)
                return object;
            var message = new $root.Msg.ChatUsers();
            if (object.curuser != null) {
                if (typeof object.curuser !== "object")
                    throw TypeError(".Msg.ChatUsers.curuser: object expected");
                message.curuser = $root.Msg.UserItem.fromObject(object.curuser);
            }
            if (object.users) {
                if (!Array.isArray(object.users))
                    throw TypeError(".Msg.ChatUsers.users: array expected");
                message.users = [];
                for (var i = 0; i < object.users.length; ++i) {
                    if (typeof object.users[i] !== "object")
                        throw TypeError(".Msg.ChatUsers.users: object expected");
                    message.users[i] = $root.Msg.UserItem.fromObject(object.users[i]);
                }
            }
            return message;
        };

        /**
         * Creates a plain object from a ChatUsers message. Also converts values to other types if specified.
         * @function toObject
         * @memberof Msg.ChatUsers
         * @static
         * @param {Msg.ChatUsers} message ChatUsers
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        ChatUsers.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.arrays || options.defaults)
                object.users = [];
            if (options.defaults)
                object.curuser = null;
            if (message.curuser != null && message.hasOwnProperty("curuser"))
                object.curuser = $root.Msg.UserItem.toObject(message.curuser, options);
            if (message.users && message.users.length) {
                object.users = [];
                for (var j = 0; j < message.users.length; ++j)
                    object.users[j] = $root.Msg.UserItem.toObject(message.users[j], options);
            }
            return object;
        };

        /**
         * Converts this ChatUsers to JSON.
         * @function toJSON
         * @memberof Msg.ChatUsers
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        ChatUsers.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return ChatUsers;
    })();

    return Msg;
})();

module.exports = $root;
